     //引入的是一级路由
// import Home from '@/pages/Home';
// import Search from '@/pages/Search';
// import Login from '@/pages/Login';
// import Register from '@/pages/Register';
// import Detail from '@/pages/Detail';
// import AddCartSuccess from '@/pages/AddCartSuccess';
// import ShopCart from '@/pages/ShopCart';
// import Trade from '@/pages/Trade';
// import Pay from '@/pages/Pay';
// import PaySuccess from '@/pages/PaySuccess';
// import Center from '@/pages/Center';
// import groupOrder from '@/pages/Center/groupOrder';
// import myOrder from '@/pages/Center/myOrder';
export default [
        {
            name:'home',
            path:'/home',
            //路由懒加载
            //component右侧的值：防止一个箭头函数，当这个home路由组件被访问的时候执行
            component:()=>import('@/pages/Home'),
            //路由元信息===控制footer的显示与隐藏
            meta:{show:true},
        },
        {  //代表params参数可有可无，务必要加上问号 ?
            path:'/search/:keyWord?',
            component:()=>import('@/pages/Search'),
            meta:{show:true},
            //命名路由
            name:'search',
            //路由也可以传递props数据，拥有三种写法
            //如果props被设置为true ,param参数将会被设置为组件属性
            //  props:true
            props:(route)=>({keyWord:route.params.keyWord,k:route.query.k})
        },
        {   
            name:'login',
            path:'/login',
            component:()=>import('@/pages/Login'),
            meta:{show:false},
        },
        {   
            name:'register',
            path:'/register',
            component:()=>import('@/pages/Register'),
            meta:{show:false},
        },
        {  //页面重定向
            path:'/', 
            redirect:'/home'
        },
        {
            path:'/detail/:skuId',
            component:()=>import('@/pages/Detail'),
            meta:{show:true},
        },
        //加入购物车路由
        {
            name:"addcartsuccess",
            path:'/addcartsuccess',
            component:()=>import('@/pages/AddCartSuccess'),
            meta:{show:true},
        },
        {
            name:"shopcart",
            path:'/shopcart',
            component:()=>import('@/pages/ShopCart'),
            meta:{show:true},
        },
        //交易页面路由：书写在这里的路由
        {
            name:"trade",
            path:'/trade',
            component:()=>import('@/pages/Trade'),
            meta:{show:true},
            beforeEnter: (to, from, next) => {
                //从购物车的路由页面跳转到交易页面
                if(from.path=='/shopcart'){
                    next();
                }else{
                    next(false);
                }
            }
        },
        {
            name:"pay",
            path:'/pay',
            component:()=>import('@/pages/Pay'),
            meta:{show:true},
            beforeEnter: (to, from, next) => {
                //进入支付页面必须从交易的路由页面跳转到支付页面
                if(from.path=='/trade'){
                    next();
                }else{
                    next(false);
                }
            }
        },
        {
            name:"paysuccess",
            path:'/paysuccess',
            component:()=>import('@/pages/PaySuccess'),
            meta:{show:true},
            beforeEnter: (to, from, next) => {
                //进入支付成功页面必须从支付页面进入
                if(from.path.indexOf('/pay')!=-1){
                    next();
                }else{
                    next(false)
                }
            }
          
        },
        {
            name:"center",
            path:'/center',
            component:()=>import('@/pages/Center'),
            meta:{show:true},
            children:[
                //我的订单二级路由
                {
                    path:"myorder",
                    component:()=>import('@/pages/Center/myOrder'),
                },
                {
                    path:"grouporder",
                    component:()=>import('@/pages/Center/groupOrder'),
                },
                {   //页面重定向
                    path:'/center',
                    redirect:'/center/myorder'
                }
            ]
        }
    ]

 